﻿namespace DimensionsHelper.Common.Metadata.Script;

/// <summary>
///     整数常量表达式。
/// </summary>
public class IntegerExpression : LiteralExpression
{
    /// <summary>
    ///     整数常量表达式。
    /// </summary>
    public IntegerExpression(int start) : base(LiteralKinds.Integer, start)
    {
    }

    /// <summary>
    ///     当前整数的具体数值，无效值是<see cref="int.MaxValue" />
    /// </summary>
    public int Value { get; private set; } = int.MaxValue;

    public override ExpressionBasicType Evaluate()
    {
        return new ExpressionInteger(Value);
    }

    public override void Finish(int end, string text)
    {
        base.Finish(end, text);
        Value = int.Parse(text);
    }
}